<template>
  <rx-app>
    <!-- 头部 -->
    <rx-header :header="header"></rx-header>
    <!-- 侧栏 -->
    <rx-aside :slideBar="slideBar" @menuClickCall="menuClickCall"></rx-aside>
    <!-- 主内容 -->
    <rx-main>
      <!-- 固定标题切换 -->
      <div id="components-title">
            <!-- 城-项目管理 -->
            <ul class="clearfix uiTab1 mb5" v-if="(route == '/projectFilesCityCon/CityProject' || route == '/projectFilesCityCon/CityOrder' || route == '/projectFilesCityCon/CityOrderStatic')">
                <router-link tag="li" class="col-md-3 fl" to="/projectFilesCityCon/CityProject" active-class="uiTab1-active"><a href="javascript:">项目</a></router-link>
                <router-link tag="li" class="col-md-3 fl" to="/projectFilesCityCon/CityOrder" active-class="uiTab1-active"><a href="javascript:">订单</a></router-link>
                <router-link tag="li" class="col-md-3 fl" to="/projectFilesCityCon/CityOrderStatic" active-class="uiTab1-active"><a href="javascript:">模板</a></router-link>
            </ul>
        </div>
        <!-- 具体业务内容 -->
        <router-view></router-view>
        <!-- 消息弹出 -->
        <rx-tips></rx-tips>
    </rx-main>
  </rx-app>
</template>
<script>
import rxTips from './Tips/Index.vue'
import { sliderMenu } from '@modules/CityConstruction/Common/Utils/menu.js'
import { mapMutations, mapGetters } from 'vuex'
export default {
    metaInfo: {
        title: '瑞祥施工',
        titleTemplate: '%s'
    },
    components: {
        rxTips
    },
    data () {
        return {
            // header 传值对象
            header: {
                title: '瑞祥工总经理',
                list: [
                    {
                        name: '反馈',
                        flag: 0,
                        count: 0,
                        icon: 'https://pa.rxjy.com/abc/images/header/feedback.png'
                    }
                ]
            },
            // slideBar 传值对象
            slideBar: sliderMenu,
            // slideBar 返回对象
            menuCall: {},
            route: '',
            currentaroute: ''
        }
    },
    computed: {
        ...mapGetters(['userInfo'])
    },
    created () {
        this.route = this.$route.matched[1].path
        this.loginVerification()
    },
    methods: {
        ...mapMutations({setUserInfo: `SET_USER_INFO`}),
        menuClickCall (data) {
            this.menuCall = data
        },
        // 登录判断
        loginVerification () {
            if (localStorage.getItem('userInfo') === null) {
                // 判断是否有jwt值
                if (this.$route.query.jwt) {
                    let results = {}
                    results.as_jwt = this.$route.query.jwt // jwt
                    this.setUserInfo({...results})
                }
                this.$router.push({path: '/'})
                return false
            }
        }
    },
    watch: {
        $route () {
            this.route = this.$route.matched[1].path
            //   this.$utils.removeSession('menuInit')
            /**
            *  判断是否有登录信息
            *  没有进入提示登录页面
            *  存在登录信息
            *      判断是否正式环境
            *          如果是 验证登录超时
            *              判断存储的登录时间戳 是否超时两个小时
            *              登录超时后 会清空localStorage里存储的用户信息
            */
            //   if (localStorage.getItem('userInfo') === null) {
            //             this.$router.push({ path: '/' }) // 跳转到登录
            //     this.$utils.clearLocal() // 清空当前浏览器存储的localStorage
            //     return false
            //   }
        }
    }
}
</script>
